package com.jike.shop.cloud.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.HashMap;
import java.util.Map;

@Getter
@RequiredArgsConstructor
public enum PaymentChannelEnum {
    UNKNOWN("unknown", "unknown", ""),
    WECHAT("wechat", "微信支付", "wechatPayService"),
    ALIPAY("alipay", "支付宝", "alipayService"),
    ;


    private final String code;

    private final String desc;

    private final String serviceName;

    private static final Map<String, PaymentChannelEnum> MAP = new HashMap<>();

    static {
        for (PaymentChannelEnum value : values()) {
            MAP.put(value.code, value);
        }
    }

    public static PaymentChannelEnum getByCode(String code) {
        return MAP.getOrDefault(code, UNKNOWN);
    }
}
